//
//  SpecialTableViewCell.m
//  BTRIP
//
//  Created by dllo on 15/11/13.
//  Copyright © 2015年 johnbk. All rights reserved.
//

#import "SpecialTableViewCell.h"
#import <SDWebImageManager.h>
#import <UIImageView+WebCache.h>
@implementation SpecialTableViewCell

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (void)dealloc{
    [_nameLabel release];
    [_picImage release];
    [_titleLabel release];
    [_smallLabel release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        self.picImage = [[UIImageView alloc]init];
//        self.picImage.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:self.picImage];
        [_picImage release];
        
        self.smallLabel = [[UILabel alloc]init];
        self.smallLabel.backgroundColor = [UIColor blackColor];
        self.smallLabel.alpha = 0.11;
        [self.contentView addSubview:self.smallLabel];
        [_smallLabel release];
        
        self.nameLabel = [[UILabel alloc]init];
//        self.nameLabel.backgroundColor = [UIColor orangeColor];
        [self.contentView addSubview:self.nameLabel];
        [_nameLabel release];
        
        self.titleLabel = [[UILabel alloc]init];
//        self.titleLabel.backgroundColor = [UIColor brownColor];
        [self.contentView addSubview:self.titleLabel];
        [_titleLabel release];
        
    }
    return self;
}

- (void)layoutSubviews{
    [super layoutSubviews];
    self.picImage.frame = CGRectMake(10 * SWIDTH, 5 * SWIDTH, KWIDTH - 20 * SWIDTH, KHEIGHT / 2.5 - 10 * SWIDTH);
    self.picImage.layer.cornerRadius = 5;
    self.picImage.layer.masksToBounds = YES;
    
    self.smallLabel.frame = CGRectMake(self.picImage.frame.origin.x, 205 * SWIDTH, self.picImage.frame.size.width, 57 * SWIDTH);
    self.nameLabel.frame = CGRectMake(20 * SWIDTH, 190 * SWIDTH, KWIDTH - 40 * SWIDTH, 50 * SWIDTH);
    self.titleLabel.frame = CGRectMake(self.nameLabel.frame.origin.x, self.nameLabel.frame.size.height + self.nameLabel.frame.origin.y - 20 * SWIDTH, self.nameLabel.frame.size.width, 40 * SWIDTH);
}

- (void)setSpecial:(SpecialModel *)special{
    if (_special != special) {
        [_special release];
        _special = [special retain];
    }
    
    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@",special.image_url]];
    [self.picImage sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"background"]];
    self.nameLabel.text = special.name;
    self.nameLabel.textColor = [UIColor whiteColor];
    [self.nameLabel setFont:[UIFont systemFontOfSize:20]];
    self.titleLabel.text = special.title;
    self.titleLabel.textColor = [UIColor whiteColor];
    
    
}


@end
